module_adapter: dp: Improve module adapter creation function#10565
Merged
lgirdwood merged 5 commits intothesofproject:mainfrom Feb 24, 2026
Merged
module_adapter: dp: Improve module adapter creation function#10565lgirdwood merged 5 commits intothesofproject:mainfrom
lgirdwood merged 5 commits intothesofproject:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error handling and initialization order in the module adapter creation flow for data processing tasks. The changes ensure that task creation failures are properly detected and handled, prevent potential use-after-free issues, and guarantee that module fields are initialized before the DP thread can access them.
Changes:
- Add error checking for DP task initialization to catch creation failures
- Fix task pointer assignment to only occur on successful initialization
- Reorder module field initialization to happen before DP thread creation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/schedule/zephyr_dp_schedule_thread.c | Modified scheduler_dp_task_init() to defer task pointer assignment until after successful thread creation |
| src/audio/module_adapter/module_adapter.c | Added error handling for DP task creation and moved module field initialization before thread creation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b7ea2ac to
db5625c
Compare
lyakh
approved these changes
Feb 23, 2026
lgirdwood
approved these changes
Feb 23, 2026
serhiy-katsyuba-intel
approved these changes
Feb 23, 2026
Move mod field initialization in module_adapter_new_ext() before creating the dp thread. Moving the initialization earlier prevents the dp thread from use uninitialized data. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Check the value returned by the pipeline_comp_dp_task_init() call in module_adapter_new_ext(). Update scheduler_dp_task_init() to assign the output task structure pointer only on success. The function allocates task structure and free it on failure. Returning a non-null task on error could lead to a double free in the module adapter or use after free. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Fix use after free in module_adapter_new_ext() by removing the dst access after freeing mod. The dst points to a field inside the previously allocated mod structure. The structure is freed on error so its fields do not need to be cleared beforehand. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
db5625c to
6de726a
Compare
Remove the no longer needed user_memory_init_shared(). Add the dp thread to the memory domain directly in the dp scheduler. The function originally added the common partition to the memory domain and added thread to that domain. The userspace proxy now adds the common partition to memory domain, so the function cannot perform this step. Grant access to thread only when userspace is used. Kernel threads have access to all the memory, no need to additionally grant access to them. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Total of 153 commits. Changes include: d885cfebaa3 soc: intel_adsp/ace: Fix MMU mapping for shared heap bb8d441d201 tests: llext: add harvard to scope, build for nsim/nsim_em ebf1f9d019b tests: llext: fixes for arcmwdt, gcc Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
6de726a to
f2a7c05
Compare
wjablon1
approved these changes
Feb 24, 2026
abonislawski
approved these changes
Feb 24, 2026
tmleman
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pipeline_comp_dp_task_init()to ensure the dp thread is created successfully. This prevents execution from continuing with an invalid task.scheduler_dp_task_init()to assign the output task pointer only on success. The function frees the allocated task structure on failure, so returning a non-null task could lead to a double free or use after free.module_adapter_new_ext()to occur before creating the dp thread. This prevents the thread from use uninitialized fields.